package com.yelink.metrics.cases.service.impl;

import cn.hutool.json.JSONUtil;
import com.yelink.metrics.api.MetricsApi;
import com.yelink.metrics.api.time.DailyVO;
import com.yelink.metrics.cases.entity.DemoDailyEntity;
import com.yelink.metrics.cases.mapper.DemoDailyMapper;
import com.yelink.metrics.core.domain.TargetModel;
import com.yelink.metrics.core.service.BaseMetricsService;
import com.yelink.metrics.core.service.BaseMetricsServiceImpl;

import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;


/**
 * 示例模板
 * @author idea
 */
@Slf4j
@Service
public class DemoDailyServiceImpl extends BaseMetricsServiceImpl<DemoDailyMapper, DemoDailyEntity> implements BaseMetricsService<DemoDailyEntity> {

    @Resource
    private MetricsApi metricsApi;
    @Override
    public List<DemoDailyEntity> deal(TargetModel targetModel) {
        DailyVO daily = metricsApi.getDaily();
        log.info("时间参数：{}", JSONUtil.toJsonStr(daily));
        return Arrays.asList(
                DemoDailyEntity.builder()
                        .demo("workOrder123")
                        .recordTime(daily.getRecordTime())
                        .iaVal(1.1)
                        .build()
                ,
                DemoDailyEntity.builder()
                        .demo("workOrder456")
                        .recordTime(daily.getRecordTime())
                        .description("说明~")
                        .build()
        );
    }
}
